package top.lionkliu.listener;

import top.lionkliu.entity.OnlineCounter;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.Enumeration;

@WebListener
public class OnlineCounterListener implements HttpSessionListener, HttpSessionAttributeListener {
    public void sessionCreated(HttpSessionEvent hse) {
        OnlineCounter.raise();
        System.out.println("raise" + OnlineCounter.getOnline());
    }

    public void sessionDestroyed(HttpSessionEvent hse) {
        OnlineCounter.reduce();
        System.out.println("reduce" + OnlineCounter.getOnline());
    }
} 


